home *** CD-ROM | disk | FTP | other *** search
- /*
- File: GenerateFont.c
-
- Contains: Program to generate C source code for the InterruptSafeDebug font.
-
- Written by: Quinn "The Eskimo!"
-
- Copyright: © 1998 by Apple Computer, Inc., all rights reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- <1> 23/11/98 Quinn First checked in.
- */
-
- /////////////////////////////////////////////////////////////////////
-
- // Setup MoreIsBetter environment
-
- #include "MoreSetup.h"
-
- // Mac OS interfaces
-
- #include <MacTypes.h>
- #include <QDOffscreen.h>
- #include <Fonts.h>
-
- // Standard C interfaces
-
- #include <stdio.h>
-
- /////////////////////////////////////////////////////////////////////
-
- void main(void)
- {
- OSStatus err;
- GWorldPtr gWorld;
- Rect bounds;
- UInt8 *base;
- ByteCount rowBytes;
- ItemCount i;
- ItemCount row;
-
- printf("Hello Cruel World!\n");
- printf("QStandard.c\n");
- fflush(stdout);
-
- // Create an offscreen GWorld to hold all 256 font
- // characters, arranged horizontally.
-
- bounds.top = 0;
- bounds.left = 0;
- bounds.bottom = 10;
- bounds.right = 256 * 8;
-
- err = NewGWorld(&gWorld, 1, &bounds, nil, nil, 0);
- if (err == noErr) {
-
- // Setup the GWorld for our use.
-
- LockPixels(gWorld->portPixMap);
-
- SetGWorld(gWorld, nil);
- TextFont(kFontIDMonaco);
- TextSize(9);
- EraseRect(&bounds);
-
- // Draw all 256 characters, horizontally, into
- // the offscreen GWorld.
-
- for (i = 0; i < 256; i++) {
- MoveTo(i * 8 + 1, 7);
- DrawChar(i);
- }
-
- // Walk through the pixmap data in the GWorld,
- // printing it to stdout.
-
- base = (UInt8 *) GetPixBaseAddr(gWorld->portPixMap);
- rowBytes = ((**(gWorld->portPixMap)).rowBytes) & 0x3FFF;
- for (row = 0; row < 10; row++) {
- for (i = 0; i < 256; i++) {
- printf("0x%02x, ", *(base + (rowBytes * row) + i));
- }
- printf("\n");
- }
-
- // Clean up.
-
- DisposeGWorld(gWorld);
- }
-
- if (err == noErr) {
- printf("Success!\n");
- } else {
- printf("Failed with error %ld.\n");
- }
- printf("Done. Press command-Q to Quit.\n");
- }